<!--extend frame-->
<block_title>
    详细报告
</block_title>
<block_left>
    <a href="{{url SysNaples/Admin/report/list}}" class="list-group-item"><span class="glyphicon glyphicon-th-list"><span class="hidden-xs bold"> 报告列表</span></span></a>
    <a href="{{url SysNaples/Admin/report/del}}" class="list-group-item" onclick="if(!confirm('确定要删除所有报告吗？')){return false;}"><span class="glyphicon glyphicon-trash">
        <span class="hidden-xs bold"> 清空报告</span></span>
    </a>
    {{if $action=='read'}}
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-star"><span class="hidden-xs bold"> 任务简报</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-inbox"><span class="hidden-xs bold"> 运行环境</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-list-alt"><span class="hidden-xs bold"> 参数请求</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-time"><span class="hidden-xs bold"> 执行耗时</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-print"><span class="hidden-xs bold"> 模板引擎</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-file"><span class="hidden-xs bold"> 文件加载</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-play"><span class="hidden-xs bold"> 运行状态</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-search"><span class="hidden-xs bold"> 追踪调试</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-barcode"><span class="hidden-xs bold"> 数据访问</span></span></a>
    <a href="#" class="list-group-item btnPage"><span class="glyphicon glyphicon-remove-circle"><span class="hidden-xs bold"> 错误报告</span></span></a>
    <!--<a href="#" class="list-group-item btnPage"><span class="glyphicon  glyphicon-folder-open"><span class="hidden-xs"> 全部显示</span></span></a>-->

    {{/}}
</block_left>
<block_right>
    <style>
        .btnLines{
            cursor: pointer;
        }
    </style>

    {{if $action=='list'}}
        <table class="table table-striped table-hover table-responsive">
            {{table $reports}}
        </table>
    {{elseif $action=='del'}}
    <h3 class="text-primary">详细报告删除完成!</h3>
    {{elseif $action=='read' and $reportArr}}
        <div class="page hide">
            <!--简报-->
            {{each $reportArr['简报'] $key $value}}
            <div class="panel panel-info">
                <div class="panel-heading">
                    <h3 class="panel-title">{{:key}}</h3>
                </div>
                {{if is_array($value)}}
                <table class="table table-striped table-hover table-responsive table-bordered">
                    {{each $value $k $v}}
                    <tr>
                        <td>{{:k}}</td>
                        <td>
                            {{if is_array($v)}}
                            {{if !empty($v)}}
                            {{dump $v}}
                            {{else}}
                            null
                            {{/}}
                            {{else}}
                            {{:v}}
                            {{/}}
                        </td>
                    </tr>
                    {{/}}
                </table>
                {{else}}
                <div class="panel-body">
                    {{:value}}
                </div>
                {{/}}
            </div>
            {{/}}

        </div>
        <div class="page hide">
            <!--环境-->
            {{each $reportArr['环境'] $key $value}}
            <div class="panel panel-info">
                <div class="panel-heading">
                    <h3 class="panel-title">{{:key}}</h3>
                </div>
                {{if is_array($value)}}
                <table class="table table-striped table-hover table-responsive table-bordered">
                    {{each $value $k $v}}
                    <tr>
                        <td>{{:k}}</td>
                        <td>
                            {{if is_array($v)}}
                            {{if !empty($v)}}
                            {{dump $v}}
                            {{else}}
                            null
                            {{/}}
                            {{else}}
                                {{if $v===true}}
                                    true
                                {{elseif $v===false}}
                                    false
                                {{elseif is_null($v)}}
                                    null
                                {{else}}
                                    {{:v}}
                                {{/}}
                            {{/}}
                        </td>
                    </tr>
                    {{/}}
                </table>
                {{else}}
                <div class="panel-body">
                    {{:value}}
                </div>
                {{/}}
            </div>
            {{/}}
        </div>
        <div class="page hide">
            <!--请求-->
            {{each $reportArr['请求'] $key $value}}
            <div class="panel panel-info">
                <div class="panel-heading">
                    <h3 class="panel-title">{{:key}}</h3>
                </div>
                {{if is_array($value)}}
                <table class="table table-striped table-hover table-responsive table-bordered">
                    {{each $value $k $v}}
                    <tr>
                        <td>{{:k}}</td>
                        <td>
                            {{if is_array($v)}}
                            {{if !empty($v)}}
                            {{dump $v}}
                            {{else}}
                            null
                            {{/}}
                            {{else}}
                            {{:v}}
                            {{/}}
                        </td>
                    </tr>
                    {{/}}
                </table>
                {{else}}
                <div class="panel-body">
                    {{:value}}
                </div>
                {{/}}
            </div>
            {{/}}

        </div>
        <div class="page hide">
            <!--耗时-->
            <table class="table table-striped table-hover table-responsive table-condensed">
                {{each $reportArr['耗时'] $k $v}}
                <tr>
                    <td>{{:k}}</td>
                    <td>
                        {{if is_array($v)}}
                        {{if !empty($v)}}
                        {{dump $v}}
                        {{else}}
                        null
                        {{/}}
                        {{else}}
                        {{:v |noe}}
                        {{/}}
                    </td>
                </tr>
                {{/}}
            </table>
        </div>
        <div class="page hide">
            <!--模板-->
            {{each $reportArr['模板'] $key $value}}
            <div class="panel panel-info">
                <div class="panel-heading">
                    <h3 class="panel-title">{{:key}}</h3>
                </div>
                {{if is_array($value)}}
                <table class="table table-striped table-hover table-responsive table-bordered">
                    {{each $value $k $v}}
                    <tr>
                        <td>{{:k}}</td>
                        <td>
                            {{if is_array($v)}}
                            {{if !empty($v)}}
                            {{dump $v}}
                            {{else}}
                            null
                            {{/}}
                            {{else}}
                            {{:v}}
                            {{/}}
                        </td>
                    </tr>
                    {{/}}
                </table>
                {{else}}
                <div class="panel-body">
                    {{:value}}
                </div>
                {{/}}
            </div>
            {{/}}
        </div>
        <div class="page hide">
        <!--加载-->
        <table class="table table-striped table-hover table-responsive table-bordered">
            {{each $reportArr['加载'] $k $v}}
            <tr>
                <td>{{:k}}</td>
                <td>
                    {{if is_array($v)}}
                    {{if !empty($v)}}
                    {{dump $v}}
                    {{else}}
                    null
                    {{/}}
                    {{else}}
                    {{:v}}
                    {{/}}
                </td>
            </tr>
            {{/}}
        </table>
    </div>
        <div class="page hide">
        <!--运行-->
        {{each $reportArr['运行'] $key $value}}
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">{{:key}}</h3>
            </div>
            {{if is_array($value)}}
            <table class="table table-striped table-hover table-responsive table-bordered">
                {{each $value $k $v}}
                <tr>
                    <td>{{:k}}</td>
                    <td>
                        {{if is_array($v)}}
                        {{if !empty($v)}}
                        {{dump $v}}
                        {{else}}
                        null
                        {{/}}
                        {{else}}
                        {{:v}}
                        {{/}}
                    </td>
                </tr>
                {{/}}
            </table>
            {{else}}
            <div class="panel-body">
                {{:value}}
            </div>
            {{/}}
        </div>
        {{/}}
        </div>
        <div class="page hide">
        <!--调试-->
        {{each $reportArr['调试'] $key $value}}
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">{{:key}}</h3>
            </div>
            {{if is_array($value)}}
            <table class="table table-striped table-hover table-responsive table-bordered">
                {{each $value $k $v}}
                <tr>
                    <td>{{:k}}</td>
                    <td>
                        {{if is_array($v)}}
                        {{if !empty($v)}}
                        {{dump $v}}
                        {{else}}
                        null
                        {{/}}
                        {{else}}
                        {{:v}}
                        {{/}}
                    </td>
                </tr>
                {{/}}
            </table>
            {{else}}
            <div class="panel-body">
                {{:value}}
            </div>
            {{/}}
        </div>
        {{/}}
        </div>
        <div class="page hide">
        <!--数据-->
        {{each $reportArr['数据'] $key $value}}
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title">{{:key}}</h3>
            </div>
            {{if is_array($value)}}
            <table class="table table-striped table-hover table-responsive table-bordered">
                {{each $value $k $v}}
                <tr>
                    <td>{{:k}}</td>
                    <td>
                        {{if is_array($v)}}
                        {{if !empty($v)}}
                        {{dump $v}}
                        {{else}}
                        null
                        {{/}}
                        {{else}}
                        {{:v}}
                        {{/}}
                    </td>
                </tr>
                {{/}}
            </table>
            {{else}}
            <div class="panel-body">
                {{:value}}
            </div>
            {{/}}
        </div>
        {{/}}
        </div>
        <div class="page hide">
        <!--错误-->
            <div class="panel-group" id="accordion">
                {{each $reportArr['错误'] $key $value}}
                <div class="panel panel-danger">
                    <div class="panel-heading" id="panel-heading{{:key}}">
                        <h4 class="panel-title" onclick="initRender('{{:key}}')">
                            <a class="active" data-toggle="collapse" data-parent="#accordion"
                               href="#collapse{{:key}}">
                               {{:key}} - {{:value.type}} - {{:value.msg}}
                            </a>
                        </h4>
                    </div>
                    <div id="collapse{{:key}}" class="panel-collapse collapse in"></div>
                    <script>
                        var collapse_value_
                        {
                            {:
                                key
                            }
                        }
                        = {
                        {
                                ? echo json_encode($value)
                        }
                        }
                        ;
                    </script>

                </div>
                {{/}}
            </div>
        <!--<div class="page hide">{{*dump $reportArr}}</div>-->


        <script>
            $(function () {
                var pages=$('.page');
                var btnPages=$('.btnPage');
                btnPages.each(function (i) {
                    $(this).attr('index',i);
                    $(this).on('click',function () {
                        var page=pages[$(this).attr('index')];
                        $(page).removeClass('hide');
                        $(page).siblings('.page').addClass('hide');
                        $(this).addClass('active');
                        $(this).siblings('.active').removeClass('active');
                        return false;
                    })
                });
                btnPages.first().click();
                $('#accordion a:first').click();
                $(document).on("click", ".btnLines", function () {
                    $(this).siblings('.fileShot').slideToggle()
                });
            });
            //加载错误渲染
            var nap = new Naples();
            function initRender(key) {
                var id = 'collapse' + key;
                var e = $("#" + id);
                if (e.html() == '') {
                    $.ajax({
                        type: "POST",
                        url: "{{url reportErrorRender based}}",
                        data: {
                            data: window['collapse_value_' + key],
                            key: key
                        },
                        dataType: "json",
                        async: true,

                        success: function (data) {
                            nap.log('读取文件信息[' + key + ']');
                            var html = data.data;
                            e.html(html);
                        },
                        error: function () {
                            alert('错误，远程服务器没有响应.')
                        }
                    });
                }
            }
        </script>
    {{else}}
    <div class="container">
        <div class="jumbotron" style="background-color: inherit">
            <h2>发生错误</h2>
            <p>找不到指定的详细报告，请检查输入是否有误。</p>
            <p><a class="btn btn-primary btn-lg" role="button" href="{{url SysNaples/Admin/report/list}}">
                返回列表</a>
            </p>
        </div>
    </div>
    {{/}}

</block_right>
<block_bottom>

</block_bottom>
